﻿using System;
using System.Collections.Generic;
using STeaL.Functional;

namespace STeaL.Algorithm {
  public static partial class IListExtensions {
#region resize
    public static void resize<T>(this IList<T> list, int sz, T item) {
      if (list.Count < sz) {
        while (list.Count != sz) list.Add(item);
      } else {
        while (list.Count != sz) list.RemoveAt(list.Count - 1);
      }
    }

    public static void resize<T>(this IList<T> list, int sz) {
      resize(list,sz,default(T));
    }

#endregion
  }
}
